package com.cy.pj.eiems.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.pj.eiems.Exception.ServiceException;
import com.cy.pj.eiems.dao.EiemsAgencyCommentDao;
import com.cy.pj.eiems.entity.EiemsAgencyInformation;
import com.cy.pj.eiems.entity.MoreTableData;
import com.cy.pj.eiems.service.EiemsAgencyCommentService;
import com.cy.pj.eiems.vo.PageObject;

@Service
public class EiemsAgencyCommentServiceImpl implements EiemsAgencyCommentService{

	@Autowired
	private EiemsAgencyCommentDao eiemsAgencyInformationDao;

@Override
public PageObject<MoreTableData> findObjects(
		Integer name, Integer pageCurrent) {
	if(pageCurrent==null||pageCurrent<1)
		throw new IllegalArgumentException("当前页码值不正确");
		//2.基于用户名查询总记录数并进行校验
		int rowCount=eiemsAgencyInformationDao.getRowCount(name);
		if(rowCount==0)
		throw new ServiceException("记录不存在");
		//3.查询当前页记录
		Integer pageSize=8;
		Integer startIndex=(pageCurrent-1)*pageSize;
		List<MoreTableData> records=
				eiemsAgencyInformationDao.findObjects(name,
				startIndex, pageSize);
		//4.封装查询结果并返回
		return new PageObject<>(pageCurrent, pageSize, rowCount, records);
		
}
}
